/**
 * ENGLISH VOLUME UNITS
 * Contains CUBICINCHES, CUBICFEET, CUBICYARDS
 * METRIC BASE: CUBICMETERS
 * Each unit is set up as:
 * 
 * UNITS {
 * 
 * 	-- Returns value in same units --
 * 	public double toUnits(double value){
 * 		return value;
 * 	}
 * 
 * 	-- Returns value in other units --
 * 	-- One method for each type in category --
 * 	-- Example: UNITS = INCHES, value = 18, Convert toFeet, Return = 1.5 (Feet)
 * 	public double toOtherUnits(double value){
 * 		return value ( / or * ) ####;
 * 	}
 * 		
 * 	-- Converts value value of Unit type sourceUnit into UNITS type --
 * 	-- Example: UNITS = INCHES, value = 1.5, sourceUnit = FEET, return = 18 (Inches)
 * 	public double convert (double value, EnglishUnit sourceUnit){
 * 		return sourceUnit.toUnits(value);
 *	}
 * }
 */

package umuc.cmsc495.mach2.unit.english;

/**
 * @author Michael Swann
 */
public enum EnglishVolumeUnit {
    CUBICINCHES {
	@Override
	public double toCubicInches(double value) {
	    return value;
	}

	@Override
	public double toCubicFeet(double value) {
	    return value / 1728;
	}

	@Override
	public double toCubicYards(double value) {
	    return value / 46655.9999795711;
	}

	@Override
	public double toCubicMeters(double value) {
	    return value / 61023.7441;
	}

	@Override
	public double convert(double value, EnglishVolumeUnit sourceUnit) {
	    return sourceUnit.toCubicInches(value);
	}
    },

    CUBICFEET {
	@Override
	public double toCubicInches(double value) {
	    return value * 1728;
	}

	@Override
	public double toCubicFeet(double value) {
	    return value;
	}

	@Override
	public double toCubicYards(double value) {
	    return value / 27;
	}

	@Override
	public double toCubicMeters(double value) {
	    return value / 35.3146667;
	}

	@Override
	public double convert(double value, EnglishVolumeUnit sourceUnit) {
	    return sourceUnit.toCubicFeet(value);
	}
    },

    CUBICYARDS {
	@Override
	public double toCubicInches(double value) {
	    return value * 46655.9999795711;
	}

	@Override
	public double toCubicFeet(double value) {
	    return value * 27;
	}

	@Override
	public double toCubicYards(double value) {
	    return value;
	}

	@Override
	public double toCubicMeters(double value) {
	    return value / 1.30795062;
	}

	@Override
	public double convert(double value, EnglishVolumeUnit sourceUnit) {
	    return sourceUnit.toCubicYards(value);
	}
    };

    /**
     * @param sourceValve
     *            Value in Source Units
     * @param sourceUnit
     *            Source Unit Type
     * @return Value in Target Units
     */
    public abstract double toCubicInches(double value);

    public abstract double toCubicFeet(double value);

    public abstract double toCubicYards(double value);

    public abstract double toCubicMeters(double value);

    public abstract double convert(double sourceValve, EnglishVolumeUnit sourceUnit);
}
